#ifndef _HUF
#include <stdio.h>
#endif

// element of Huffman's Tree
typedef struct __HufTree {
	unsigned flag : 1; // leaf - 0 ; tie - 1
	unsigned char alpha; 
	unsigned long long int count; // alpha's rate in file
	struct __HufTree * top;
	struct __HufTree * left;
	struct __HufTree * right;
} __HufTree;

// File's head
typedef struct fileHead {
	size_t sizeName; // length of name
	char * fileName; 
	unsigned long long int mtime; //time of last modification
	unsigned long long int fileSize; 
	size_t huff_ubits; // bits in compress file that were not used
	size_t huff_block; // size of Huffman's Tree in bites
	unsigned long long int huff_file_len; // size of compressed file
	short int rplFlag;
	//__HufTree * HufTree;
	// useful flags which uses in differet functions
} fileHead;

// This struct is used in encryption
typedef struct str_inf {
	size_t cur_pos;
	size_t max_pos;
	size_t ind_bits;
	size_t ind_char;
	size_t u_bits;
} str_inf;

typedef struct str_inf_dec {
	size_t cur_pos;
	size_t max_pos;
	size_t u_bits;
	size_t ind_char;
	size_t ind_bit;
	__HufTree * head;
	__HufTree * elm;
}	str_inf_dec;

//this struct is used for clearing memory before aborts, or exit;
typedef struct _env {
	FILE * old_arc;
	FILE * new_arc;
	FILE * fileToRead;
	FILE * fileToWrite;
	FILE * tmpFile_1;
	char * tmpArcName;
	char ** fileNames;
	char * tmpFileName;
	char * buf;
	unsigned char *	hufTreeinStr;
	unsigned char * buf_2;
	unsigned char ** tables;
	__HufTree  * HufTree;
	__HufTree ** HufTree_list;
	fileHead * fileHd;
	fileHead ** list;
	struct stat * fileStat;
	str_inf * inf;
	str_inf_dec * inf_2;
} _env;